import java.util.*;

public class Test {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        list.sort((a,b) -> a-b);
    }
}
class StockPrice {
    int max_Time = 0;
    HashMap<Integer,Integer> timestampMap;
    TreeMap<Integer,Integer> priceMap;

    public StockPrice() {
        timestampMap = new HashMap<>();
        priceMap = new TreeMap<>();
    }

    public void update(int timestamp, int price) {
        max_Time = Math.max(max_Time,timestamp);
        int pre_Price = timestampMap.getOrDefault(timestamp,0);
        timestampMap.put(timestamp,price);
        if(pre_Price>0){
            priceMap.put(pre_Price,priceMap.get(pre_Price)-1);
            if(priceMap.get(pre_Price)==0)
                priceMap.remove(pre_Price);
        }
        priceMap.put(price,priceMap.getOrDefault(price,0)+1);
    }

    public int current() {
        return timestampMap.get(max_Time);
    }

    public int maximum() {
        return priceMap.lastKey();
    }

    public int minimum() {
        return priceMap.firstKey();
    }
}
